/*
 * Created on 23.05.2004
 *
 * Copyright (c) 2004 The GnutellaSim Project
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
package util;

/**
 * @author bennobaumgartner
 *
 * This class can generate Unique IDs for our nodes
 */
public class IdNumberFactory {

	private static int curnr = 0;
	
	public static int getId() {
		curnr++;
		return curnr;
	}
	
	public static int getLastId() {
		return curnr;
	}
	
	private static long currentNumber = 0; 
	
	public static short[] getUniqueNumber() {
		currentNumber++;
		short[] messageId = new short[16];
		for (int i=0; i<8; i++) {
			messageId[15-i] = (short)((currentNumber>>(i*8)) & 255);
		}
		return messageId;
	}
}
